#ifndef XMLFILE_H
#define XMLFILE_H

#include <QObject>
#include <QMap>
#include <QList>
#include <QXmlStreamReader>
#include <QXmlStreamWriter>

class QXMLFile : public QObject
{
    Q_OBJECT
public:
    explicit QXMLFile(QXMLFile *parent = 0);
    ~QXMLFile();

    QList<QXMLFile*>    get_children();
    QList<QXMLFile*>    get_children_by_title(const QString &title);
    QString             get_property(const QString& name);
    QString             get_title();

    void                clear();

    void                inser_child(int index,QXMLFile* child);
    void                set_property(const QString& name,const QString& value);
    void                set_title(const QString& title);

    bool                load(const QString &buffer,QString *error);
    void                load(QXmlStreamReader *r);

    QString             write();
    void                write(QXmlStreamWriter *w);

    QMap<QString,QString>   get_propertys();

    void                set_simple();
    QString             get_text();
protected:
    QList<QXMLFile*>       m_children;
    QMap<QString,QString>   m_property;
    QXMLFile               *m_parent;
    QString                 m_title;
    QString                 m_text;
    bool                    m_simple;
};

#endif // XMLFILE_H
